package com.venusj.springcloud.service.impl;

import com.venusj.springcloud.service.ServiceIMessageProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * Created By Administrator
 * User: VenusZ
 * Date: on 2020/3/30 20:39
 * Desc:
 */
// 定义消息的推送管道
@EnableBinding(Source.class)
@Slf4j
public class ServiceIMessageProviderImpl implements ServiceIMessageProvider {

    @Resource
    private MessageChannel messageChannel;  // 消息发送管道


    public String send() {
        String serial = UUID.randomUUID().toString();
        Message<String> build = MessageBuilder.withPayload(serial).build();
        messageChannel.send(build);
        log.info("********serial:{}",serial );
        return null;
    }
}
